<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用 户 注 册</title>
<link href="css/login.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='${pageContext.request.contextPath}/dwr/engine.js'></script>
<script type='text/javascript' src='${pageContext.request.contextPath}/dwr/interface/address.js'></script>
<script type='text/javascript' src='${pageContext.request.contextPath}/dwr/util.js'></script>
<script type='text/javascript' src='${pageContext.request.contextPath}/js/jquery-1.4.4.min.js'></script>
<script type="text/javascript" >
	function showProvince(){
	   address.getAllProvinces(showProvinceBack); 
	}
	function showProvinceBack(data){
		if (typeof window['DWRUtil'] == 'undefined') 
            window.DWRUtil = dwr.util; 
	   DWRUtil.removeAllOptions('province');// 清空下拉框
	   DWRUtil.addOptions('province',['请选择省']);// 给定一个默认选项
	   DWRUtil.addOptions('province',data,'proId','proName');// 填充下拉框
	}
	
	function showCity(op){
		if(op.value=="请选择省"){
		   	DWRUtil.removeAllOptions('city');
			DWRUtil.addOptions('city',['请选择市']);
			DWRUtil.removeAllOptions('district');
			DWRUtil.addOptions('district',['请选择区']);
		}else{
			document.getElementById("selProvince").value=$("#province").find("option:selected").text();
			address.getCitiesByProId(op.value,showCityBack); 
		}
	}
		function showCityBack(data){
			if (typeof window['DWRUtil'] == 'undefined') 
	            window.DWRUtil = dwr.util; 
		   DWRUtil.removeAllOptions('city');
		   DWRUtil.addOptions('city',data,'cityId','cityName');
		   showDistrict(data[0].cityId);
		}
		
		function showDistrict(op){
			address.getDistrictsByCityId(op,showDistrictBack); 
			document.getElementById("selCity").value=$("#city").find("option:selected").text();
			   
			}
		function showDistrictBack(data){
				if (typeof window['DWRUtil'] == 'undefined') 
		            window.DWRUtil = dwr.util; 
			   DWRUtil.removeAllOptions('district');
			   DWRUtil.addOptions('district',data,'disName','disName');
			}
		function changeValidateCode(obj) {    
				//获取当前的时间作为参数，无具体意义    
				var timenow = new Date().getTime();    
				//每次请求需要一个不同的参数，否则可能会返回同样的验证码    
				//这和浏览器的缓存机制有关系，也可以把页面设置为不缓存，这样就不用这个参数了。    
				obj.src="rand.action?d="+timenow;    
				}
		function addStudent(){
				if(document.getElementById("username").value==""){
					alert("用户名不能为空！");
					document.getElementById("username").focus();
				}else if(document.getElementById("password").value==""){
					alert("密码不能为空！");
					document.getElementById("password").focus();
				}else if(document.getElementById("email").value==""){
					alert("电子邮箱不能为空！");
					document.getElementById("email").focus();
				}else if(document.getElementById("rand").value==""){
					alert("验证码不能为空！");
					document.getElementById("rand").focus();
				}else{
					document.forms[0].submit();
				}
			}
			
</script>
</head>
<body onload="showProvince();">
	<div class="logWrap logWrapIcon">
	<div class="logBg">
		<form id="user-form" action="${pageContext.request.contextPath}/student!regStudent.action" method="post">
            <div class="logBox clearfix" >
            <div class="reg1Tit clearfix">
            <h2 class="float_left" title="注册学生账号" ><span class="hidden">注册学生账号</span></h2>
              <p class="float_right"></p>
            </div>
            <ul class="reg1Con">
            <table width="500" border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td align="right" valign="middle"><span style="font-size:20px;">用&nbsp;户&nbsp;名：</span></td>
    <td align="left" valign="middle"><span><input type="text" class="logInt" name="students.userName" id="username" size="50" maxlength="50"/></span></td>
  </tr>
  <tr >
    <td align="right" valign="middle"><span style="font-size:20px;">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</span></td>
    <td align="left" valign="middle" ><span><input type="password" class="logInt" name="students.passWord" id="password" maxlength="50" size="50" style="margin-top:10px;"/></span></td>
  </tr>
  <tr >
    <td align="right" valign="middle"><span style="font-size:20px;">电子邮箱：</span></td>
    <td align="left" valign="middle" ><span><input type="text" class="logInt" name="students.email" id="email" maxlength="50" size="50" style="margin-top:10px;"/></span></td>
  </tr>
  <tr>
    <td rowspan="2" align="right" valign="middle"><span style="font-size:20px;">详细地址：</span></td>
    <td align="left" valign="middle"><span>
    	<select id="province"  onchange="showCity(this);" class="logInt" style="margin-top:10px; width:130px;"/>
        	<option value="0">请选择省</option>
        </select></span>
        <span>
    	<select id="city" onchange="showDistrict(this);"  class="logInt" style="margin-top:10px; margin-left:5px;width:100px;"/>
        	<option value="0">请选择市</option>
        </select></span>
        <span>
        <input type="hidden" name="students.address" id="selProvince">
        <input type="hidden" name="students.address" id="selCity">
    	<select name="students.address" id="district" class="logInt" style="margin-top:10px;margin-left:5px;width:100px;"/>
        	<option value="0">请选择区</option>
        </select></span>
        </td>
  </tr>
  <tr>
    <td><span><textarea name="students.address" id="address"  rows="4" cols="63" style="margin-top:10px;"></textarea></span></td>
  </tr>
  <tr>
    <td align="right" valign="middle"><span style="font-size:20px;">验&nbsp;证&nbsp;码：</span></td>
    <td align="left" valign="middle"><span><input type="text" class="logInt" name="rand" onkeyup="value=value.replace(/[^\d]/g,'')" id="rand" size="6" maxlength="6" style="margin-top:10px;"/></span>
    <img src="${pageContext.request.contextPath}/rand.action" id="randImg" title="点击图片刷新验证码"  border="0" align="middle" onclick="changeValidateCode(this);" style="width: 140px; height:37px; margin-left:5px; cursor: pointer;">
    </td>
  </tr>
</table>

            </ul>
            <span class="reg1Btn"><input class="regNow" id="regSubmit" type="button" name="yt0" value="立即注册" onclick="addStudent();"/></span>
            <span style="margin-left:40px;"><input class="regNow" id="regSubmit" type="reset" name="yt0" value="全部清空" /></span>
            </div>
            </form>
    </div>
    <div class="logBot"></div>
</div>
</body>
</html>